package org.apache.flink.runtime.resourcemanager;

import org.apache.flink.runtime.clusterframework.types.ResourceProfile;

import java.io.Serializable;

/** Class containing information about the available cluster resources. */
/**
 * @类名: ResourceOverview
 * @说明: 资源概览
 *
 * @author   leehom
 * @Date	 2024年2月21日 下午2:58:53
 * 修改记录：
 *
 * @see 	 
 */
public class ResourceOverview implements Serializable {

    private static final long serialVersionUID = 7618746920569224557L;

    private static final ResourceOverview EMPTY_RESOURCE_OVERVIEW =
            new ResourceOverview(0, 0, 0, 0, 0, ResourceProfile.ZERO, ResourceProfile.ZERO);

    /** 资源提供者数量*/
    private final int numberWorks;
    /** 注册的资源slot数量*/
    private final int numberRegisteredSlots;
    /** */
    private final int numberFreeSlots;

    private final int numberBlockedTaskManagers;

    private final int numberBlockedFreeSlots;

    private final ResourceProfile totalResource;

    private final ResourceProfile freeResource;

    public ResourceOverview(
            int numberWorkers,
            int numberRegisteredSlots,
            int numberFreeSlots,
            int numberBlockedTaskManagers,
            int numberBlockedFreeSlots,
            ResourceProfile totalResource,
            ResourceProfile freeResource) {
        this.numberWorks = numberWorkers;
        this.numberRegisteredSlots = numberRegisteredSlots;
        this.numberFreeSlots = numberFreeSlots;
        this.numberBlockedTaskManagers = numberBlockedTaskManagers;
        this.numberBlockedFreeSlots = numberBlockedFreeSlots;
        this.totalResource = totalResource;
        this.freeResource = freeResource;
    }

    public int getNumberWorkers() {
        return numberWorks;
    }

    public int getNumberRegisteredSlots() {
        return numberRegisteredSlots;
    }

    public int getNumberFreeSlots() {
        return numberFreeSlots;
    }

    public int getNumberBlockedTaskManagers() {
        return numberBlockedTaskManagers;
    }

    public int getNumberBlockedFreeSlots() {
        return numberBlockedFreeSlots;
    }

    public ResourceProfile getTotalResource() {
        return totalResource;
    }

    public ResourceProfile getFreeResource() {
        return freeResource;
    }

    public static ResourceOverview empty() {
        return EMPTY_RESOURCE_OVERVIEW;
    }
}
